home *** CD-ROM | disk | FTP | other *** search
/ Champak 128 / Vol 128 (Damaged).iso / games / chatnoir.swf / scripts / DefineSprite_33 / frame_1 / DoAction.as
Encoding:
Text File  |  2011-03-26  |  3.0 KB  |  172 lines

  1. function cat_position()
  2. {
  3.    mc = eval("mcCelLayer.mc_" + caty + "_" + catx);
  4.    mcCat._x = mc._x;
  5.    mcCat._y = mc._y;
  6.    mcCat._visible = true;
  7. }
  8. function all_disable()
  9. {
  10.    var i;
  11.    var j;
  12.    i = 0;
  13.    while(i < ymax)
  14.    {
  15.       j = 0;
  16.       while(j < xmax)
  17.       {
  18.          if(cel[i][j].stat == 1)
  19.          {
  20.             var mc = eval("mcCelLayer.mc_" + i + "_" + j);
  21.             mc.gotoAndStop(2);
  22.          }
  23.          j++;
  24.       }
  25.       i++;
  26.    }
  27. }
  28. function all_enable()
  29. {
  30.    var i;
  31.    var j;
  32.    i = 0;
  33.    while(i < ymax)
  34.    {
  35.       j = 0;
  36.       while(j < xmax)
  37.       {
  38.          var mc = eval("mcCelLayer.mc_" + i + "_" + j);
  39.          if(cel[i][j].stat == 1)
  40.          {
  41.             if(j == catx && i == caty)
  42.             {
  43.                mc.gotoAndStop(2);
  44.             }
  45.             else
  46.             {
  47.                mc.gotoAndStop(3);
  48.             }
  49.             mc._visible = true;
  50.          }
  51.          if(cel[i][j].stat == 2)
  52.          {
  53.             mc.gotoAndStop(4);
  54.             mc._visible = true;
  55.          }
  56.          j++;
  57.       }
  58.       i++;
  59.    }
  60. }
  61. addx0 = [1,0,-1,-1,-1,0];
  62. addy0 = [0,1,1,0,-1,-1];
  63. addx1 = [1,1,0,-1,0,1];
  64. addy1 = [0,1,1,0,-1,-1];
  65. xmax = 15;
  66. ymax = 15;
  67. cel = new Array();
  68. i = 0;
  69. while(i < ymax)
  70. {
  71.    cel[i] = new Array();
  72.    j = 0;
  73.    while(j < xmax)
  74.    {
  75.       cel[i][j] = new Object();
  76.       cel[i][j].stat = 0;
  77.       cel[i][j].win = 0;
  78.       j++;
  79.    }
  80.    i++;
  81. }
  82. catx = Math.floor(xmax / 2);
  83. caty = Math.floor(ymax / 2);
  84. cel[caty][catx].stat = 1;
  85. lx = new Array();
  86. ly = new Array();
  87. ld = new Array();
  88. lx[0] = catx;
  89. ly[0] = caty;
  90. lmax = 1;
  91. lx2 = new Array();
  92. ly2 = new Array();
  93. i = 2;
  94. while(i < ymax - 2)
  95. {
  96.    j = 2;
  97.    while(j < xmax - 2)
  98.    {
  99.       cel[i][j].stat = 1;
  100.       j++;
  101.    }
  102.    i++;
  103. }
  104. loop = 0;
  105. while(loop < 20)
  106. {
  107.    rx = Math.floor(Math.random() * xmax);
  108.    ry = Math.floor(Math.random() * ymax);
  109.    if(rx != catx && ry != caty)
  110.    {
  111.       if(cel[ry][rx].stat == 1)
  112.       {
  113.          cel[ry][rx].stat = 2;
  114.       }
  115.    }
  116.    loop++;
  117. }
  118. i = 0;
  119. while(i < ymax)
  120. {
  121.    j = 0;
  122.    while(j < xmax)
  123.    {
  124.       if(cel[i][j].stat == 1)
  125.       {
  126.          k = 0;
  127.          while(k < 6)
  128.          {
  129.             var nx = !(i % 2) ? j + addx0[k] : j + addx1[k];
  130.             var ny = i + addy0[k];
  131.             if(cel[ny][nx].stat == 0)
  132.             {
  133.                cel[i][j].win = 1;
  134.             }
  135.             k++;
  136.          }
  137.       }
  138.       j++;
  139.    }
  140.    i++;
  141. }
  142. w = 34;
  143. h = 26;
  144. opx = (- (xmax - 1)) * w / 2;
  145. opy = (- (ymax - 1)) * h / 2;
  146. c = 0;
  147. i = 0;
  148. while(i < ymax)
  149. {
  150.    j = 0;
  151.    while(j < xmax)
  152.    {
  153.       mcName = "mc_" + i + "_" + j;
  154.       mcCelLayer.attachMovie("mcCelOrg",mcName,c);
  155.       mc = eval("mcCelLayer." + mcName);
  156.       mc._x = opx + j * w;
  157.       if(i % 2)
  158.       {
  159.          mc._x += w / 4;
  160.       }
  161.       else
  162.       {
  163.          mc._x -= w / 4;
  164.       }
  165.       mc._y = opy + i * h;
  166.       mc._visible = false;
  167.       c++;
  168.       j++;
  169.    }
  170.    i++;
  171. }
  172.